package main

import "fmt"

//定义一个结构体
type Human struct {
	name   string
	age    int
	weight int
}

type Student struct {
	Human      //匿名字段，那么默认Student包含了Human的所有字段
	speciality string
}

func main() {
	stu := Student{Human{"Mark", 25, 120}, "计算机"}

	//访问stu的所有字段
	fmt.Println(stu)
	fmt.Println("---------------")

	fmt.Println("name:", stu.name)
	fmt.Println("name:", stu.age)
	fmt.Println("name:", stu.weight)
	fmt.Println("name:", stu.speciality)
	fmt.Println("---------------")
	//修改字段
	stu.speciality = "AI"
	stu.age = 35
	stu.weight = 180
	fmt.Println(stu)
}
